package com.lct.simpleforecast.ui.activity

import com.lct.simpleforecast.R
import com.lct.simpleforecast.extensions.setTextWithFormatArgs
import com.lct.simpleforecast.ui.activity.base.BaseActivity
import kotlinx.android.synthetic.main.activity_about.*

/**
 * 软件介绍页面
 */
class AboutActivity : BaseActivity() {
    /**
     * 设置activity的布局
     */
    override fun setLayoutResId(): Int {
        return R.layout.activity_about
    }

    /**
     * 初始化数据
     */
    override fun initData() {
        toolbar?.title = resources.getString(R.string.app_name)
        enableHomeAsUp()
        tvVersionName.setTextWithFormatArgs(R.string.version_name, getAppVersionName())
    }

    /**
     * 获取App当前的版本名称
     */
    private fun getAppVersionName(): String {
        var versionName = ""
        try {
            versionName = packageManager.getPackageInfo(packageName, 0).versionName
        } catch (e: Exception) {
        }
        return versionName
    }
}
